package com.ztgf.shopping.api.client.epg;

import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.bo.epg.EpgHotWordBO;
import com.ztgf.shopping.models.dto.epg.EpgHotWordDTO;
import com.ztgf.shopping.models.service.epg.IEpgHotWordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * author: chenyu.wang
 * date: 2020-05-18 11:19
 * Description: 热词表控制器
 */
@RestController
@RequestMapping("/api/epgHotWord")
@Slf4j
@Api(value = "EpgHotWordApiController", tags = "热词表Api接口")
public class EpgHotWordApiController {

    @DubboReference
    private IEpgHotWordService epgHotWordService;


    @PostMapping("/get")
    @ApiOperation(value = "根据id查找",notes = "根据id查找")
    @ApiImplicitParam(name = "id",value = "id",required = true,paramType = "query", dataType = "Long")
    public Result<EpgHotWordDTO> get(Long id){
        if(id == null){
            return new Result<>(CodeEnum.FAIL_100002 );
        }
        EpgHotWordDTO dto = epgHotWordService.selectById(id);
        return new Result<>(dto);
    }

    @ApiOperation(value = "热词列表")
    @PostMapping("/querySelectPageList")
    public Result< List<EpgHotWordDTO>> querySelectPageList( EpgHotWordBO bo) {
        if(null == bo)
            return new Result<>(CodeEnum.FAIL_100002 );
        List<EpgHotWordDTO> epgHotWordDTOList = epgHotWordService.getBySelectHotInfoNoPage(bo);
        return new Result<>(epgHotWordDTOList);
    }

}
